home *** CD-ROM | disk | FTP | other *** search
- /*
- * Define language 'furniture' as low-order token
- * values, this way 'keywords' can be added later
- * starting at a higher value.
- */
- #define it_DEFAULT 0
- #define it_SECTIONSTART 1
- #define it_SECTIONNAME 2
- #define it_KEYNAME 3
- #define it_VALUE 4
- #define it_EQUAL 5
- #define it_COMMENT 6
-
- /*
- * Standard stuff
- */
- #define _non_alpha_ '[^_A-Za-z0-9]'
- #define _all_chars_ '[\x00-\xFF]'
- #define _no_chars_ '[]'
- #define _dont_care_ _all_chars_
- #define _DEFAULT_BACKGROUND clWhite
- #define _DEFAULT_FOREGROUND clBlack
- /*
- * States used as below:
- *
- * ss_START Default entry state
- * ss_INSECTION Between '[' and ']'
- */
- #define ss_START 0
- #define ss_InSECTION 1
- #define ss_EQUAL 2
-
- %%language
- Name = 'INIfiles'
- Case = __INSENSITIVE
- Options = __DEFAULT_OPTIONS
- WordWrapColumn = _EDGE
- Gutter = _DEFAULT_GUTTER
- ExampleText = '[Section]\n\
- \KeyName=Value\n'
- EditableStyles ('Section', it_SECTIONSTART),
- ('Section name', it_SECTIONNAME),
- ('KeyName', it_KEYNAME),
- ('Value', it_VALUE),
- ('Equal', it_EQUAL)
-
- %%words
- //
- // Section names start with '[' at beginning of line
- //
- '\[' _dont_care_ it_SECTIONSTART [ss_START]
- '\n\[' _dont_care_ it_SECTIONSTART [ss_START]
- //
- // Properties are indicated by '=' within the line
- //
- '=' _dont_care_ it_VALUE [ss_START]
- '=' _dont_care_ it_EQUAL [ss_EQUAL]
- '\n' _dont_care_ it_KEYNAME [ss_START]
- '\n;' _dont_care_ it_COMMENT [ss_START]
-
- /*
- * Handlers...
- *
- * '['......Everything up to next ']' or end of line
- * '='......Everything up to end of line
- */
- %%handler
- it_SECTIONSTART _all_chars_? '[\]\n]' _use_
- it_VALUE '[^\n\xFF]'? '[\n\xFF]' _discard_
- it_COMMENT _all_chars_? '\n' _discard_
- it_KEYNAME Match(1)
-
- /*
- * Tokens...
- *
- * Keyname...
- */
- %%tokens
- it_SECTIONNAME '[^\[\n]' '[^\]\n]' '[\]\n]' _discard_ [ss_INSECTION]
-
- %%effects
- it_DEFAULT [] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- it_SECTIONSTART [fsBold] clBlue _DEFAULT_BACKGROUND
- it_EQUAL [fsBold] clAqua _DEFAULT_BACKGROUND
- it_KEYNAME [fsBold] clMaroon _DEFAULT_BACKGROUND
- it_VALUE [] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- it_COMMENT [fsItalic] clBlue _DEFAULT_BACKGROUND
- it_SECTIONNAME [fsBold, fsUnderline] clRed _DEFAULT_BACKGROUND
-
- %%map
- it_DEFAULT it_DEFAULT
- it_SECTIONSTART it_SECTIONSTART
- it_KEYNAME it_KEYNAME
- it_VALUE it_VALUE
- it_EQUAL it_EQUAL
- it_SECTIONNAME it_SECTIONNAME
- it_COMMENT it_COMMENT
-
- %%containers
- it_SECTIONSTART (+[ss_INSECTION] -[ss_START])
- it_VALUE (+[ss_EQUAL] -[ss_START])
-
- /*
- The above script uses Match(1) to identify non-key/value pair lines.
- This requires code attached to the OnCustomParse event handler.
- Paste the following code into the event handler:
-
- //
- // INI parser support functions...
- //
- result := true;
- case ParseID of
- 1 : //
- // Newline (without recognised follower)
- //
- // Scan until one of the following is located:
- // \n ------ Return entire line as default
- // = ------ Return as key name
- //
- with IStream do begin
- while (not yyeof) and (not (yychar in [#13, '='])) do begin
- yyadvance;
- inc(kLength);
- end;
- if yyeof
- then kValue := 0 else
- case yychar of
- #13 : kValue := 0; // Default token value
- '=' : kValue := 3; // Key token value
- end;
- end;
- end;
-
- */
-
-